home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX 6.5 Applications 1999 May
/
SGI IRIX 6.5 Applications 1999 May.iso
/
dist
/
nss_fasttrack.idb
/
var
/
netscape
/
fasttrack
/
js
/
samples
/
videoapp
/
url.js.z
/
url.js
Wrap
Text File
|
1998-10-13
|
3KB
|
113 lines
/* ============================================================
FUNCTION: spaceToplus( mystring )
INPUT: mystring - the string to be converted
RETURNS: the string after it has been processed
DESCRIPTION: This function converts any spaces in 'mystring' to a + character.
This function is used to partially URL encode strings so that
they may be used in a URL as part of an HTTP GET request
(e.g. http://www..../videos.html?Science+Fiction )
This function could be expanded to do complete URL encoding, which
would include escaping other illegal characters.
============================================================ */
function spaceTOplus ( mystring )
{
var resultstr = ""
for (i = 0; i < mystring.length; i++)
{
if (mystring.charAt(i) == " ") {
resultstr += "+";
} else {
resultstr += mystring.charAt(i);
}
}
return resultstr;
}
/* ============================================================
FUNCTION: dayString( dayNum )
INPUT: dayNum - a number from 0-6 that represents a day of the week
RETURNS: the string representation of dayNum
DESCRIPTION: This function takes a number from 0-6, usually generated by
the JavaScript "getDay()" method, and converts it into the
corresponding string for that day. So, if dayNum is 0
the function returns "Sunday", if daynum is 1 the function
returns "Monday", etc.
============================================================ */
function dayString ( dayNum )
{
var resultstr = ""
if (dayNum == 0) {
resultstr = "Sunday";
} else
if (dayNum == 1) {
resultstr = "Monday";
} else
if (dayNum == 2) {
resultstr = "Tuesday";
} else
if (dayNum == 3) {
resultstr = "Wednesday";
} else
if (dayNum == 4) {
resultstr = "Thursday";
} else
if (dayNum == 5) {
resultstr = "Friday";
} else
if (dayNum == 6) {
resultstr = "Saturday";
}
return resultstr;
}
/* ============================================================
FUNCTION: datetoString( mydate )
INPUT: mydate - a date object
RETURNS: a string representation of a date object
DESCRIPTION: This function simply parses out each part of a date
object and returns the string representation of that date.
Note however that the time part of a date object (which
contains both date and time) is left out of the return string).
============================================================ */
function datetoString ( mydate )
{
var resultstr = ""
resultstr += dayString(mydate.getDay()) + ", " +
(mydate.getMonth() + 1) + "/" +
mydate.getDate() + "/" +
mydate.getYear();
return resultstr;
}